-- UIInvisibleForm
-- Created by zouyb
-- 隐形界面，用来屏蔽操作

UIInvisibleForm = class("UIInvisibleForm", function()
    return cc.Layer:create();
end);

function UIInvisibleForm.create(duration, callback, zOrder)
    return UIInvisibleForm.new(duration, callback, zOrder);
end

-- 构造函数
function UIInvisibleForm:ctor(duration, callback, zOrder)
    self:setName("UIInvisibleForm");
    local node = cc.CSLoader:createNode("layout/common/InvisibleForm.csb");
    self:addChild(node);
    self.node = node;

    zOrder = zOrder or UIMgr.TOP_MENU_ZORDER + 100000;
    self:setLocalZOrder(zOrder);

    self:resize();

	-- duration秒后自动关闭
	local function close()
		UIMgr.getCurrentScene():removeForm(self);

		if callback then
		  callback();
		end
	end

	if duration ~= nil then
	   performWithDelay(self, close, duration);
	end
end

-- 适配
function UIInvisibleForm:resize()
    local w = AlignM.frameSize.width;
    local h = AlignM.frameSize.height;
    local node = self.node;

    local BT = node:getChildByName("bt");
    BT:setContentSize(w, h);
    BT:setPosition(0, 0);
end




